/**
 * 角色
 */
import request from '@/utils/request'

interface AllocateUserRoles {
  userId: number
  roleIdList: Array<number>
}
interface Role{
    code?: string
    id?: number
    name?: string
    startCreateTime?: string
    endCreateTime?: string
    current: number
    pageNum: number
    size: number

}
interface SaveOrUpdateRole {
  name: string
  code: string
  description: string
  id: number
}
// 给用户分配角色
export const allocateUserRoles = (data: AllocateUserRoles) => {
  return request({
    method: 'POST',
    url: '/boss/role/allocateUserRoles',
    data
  })
}
export const getRolePages = (data: Role) => {
  return request({
    method: 'POST',
    url: '/boss/role/getRolePages',
    data
  })
}
export const getAllRole = () => {
  return request({
    method: 'GET',
    url: '/boss/role/all'
  })
}

export const getUserRole = (id: number) => {
  return request({
    method: 'GET',
    url: `/boss/role/user/${id}`
  })
}

export const forbidUser = (userId: number) => {
  return request({
    method: 'POST',
    url: '/boss/role/forbidUser',
    data: {
      userId
    }
  })
}

export const deleteRole = (id: number) => {
  return request({
    method: 'DELETE',
    url: `/boss/role/${id}`
  })
}
export const saveOrUpdate = (data: SaveOrUpdateRole) => {
  return request({
    method: 'POST',
    url: '/boss/role/saveOrUpdate',
    data
  })
}
export const getRole = (id: number) => {
  return request({
    method: 'GET',
    url: `/boss/role/${id}`
  })
}
